package day5;

// inherit
public class Student extends Person{
    private String className;

    // 在Java里面new子类对象的时候，首先要把父类对象new出来
    public Student() {
        // super(); //new Person();
    }

    public Student(int id, String name, int age, String className) {
        super(id, name, age);//new Person(id,name,age)
        this.className = className;
    }

    public void study() {
        System.out.println("id是"+id+"的"+name+"正在"+className+"班学习");
    }

    // 重写、覆盖
    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", className='" + className + '\'' +
                '}';
    }
}
